import os
from multiprocessing import Pool 


input_dir = os.listdir("./09.cluster_result")
input_dirs = [os.path.join("./09.cluster_result", x) for x in input_dir]

output_dir = "./10.llm_result"
os.makedirs(output_dir, exist_ok=True)


def exec_llm(input, output, multi):
    cmd = f"python 10.llm_two_step_calssifiation.py -input {input} -output {output} -multi {multi}"
    os.system(cmd)


tasks = []
for inputdir in input_dirs:
    inputs = os.listdir(inputdir)
    for file in os.listdir(inputdir):
        input_file_path = os.path.join(inputdir, file)
        
        out_dir = os.path.join("./10.llm_result", inputdir.split("/")[-1])
        os.makedirs(out_dir, exist_ok=True)
        output_file_path = os.path.join(out_dir, file.split(".")[0] + ".json")
        if not os.path.exists(output_file_path):
            tasks.append((input_file_path, output_file_path, 200))

for i in tasks:
    exec_llm(i[0], i[1], i[2])